<?php
// no direct access
defined('_JEXEC') or die;

$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));

// get category 
$db		= JFactory::getDbo();
$query	= $db->getQuery(true);
$query->select("t2.id as value,t2.title as text ,t2.level");
$query->from("#__shop_category t1,#__shop_category t2");
$query->where('t2.lft BETWEEN t1.lft AND t1.rgt');
$query->group('t2.id,t2.lft,t2.rgt,t2.title');
$query->order("t2.lft asc");

// Get the options.
$db->setQuery($query);
$options = $db->loadObjectList();

// get address
$query->clear();
$query->select("t2.id as value,t2.title as text ,t2.level");
$query->from("#__shop_address t1,#__shop_address t2");
$query->where('t2.lft BETWEEN t1.lft AND t1.rgt');
$query->group('t2.id,t2.lft,t2.rgt,t2.title');
$query->order("t2.lft asc");

// Get the options.
$db->setQuery($query);
$address = $db->loadObjectList();

// get Company
$query->clear();
$query->select("id as value, vtitle as text");
$query->from("#__shop_product");
$query->order("id ASC");

$db->setQuery($query);
$company = $db->loadObjectList();


function getText($longText,$numWords){
	$ret="";
	if($longText!=""){
		$longText=trim($longText);
		$longText=stripslashes($longText);
		$longText=strip_tags($longText);
		$arrayText=explode(" ",$longText);
		if(count($arrayText)>$numWords){
			for($i=0;$i<$numWords;$i++){
				$ret.=$arrayText[$i]." ";
			}
			$longText=trim($ret)."..";
			return $longText;
		}
		else{
			return $longText;
		}
	}
}

require JModuleHelper::getLayoutPath('mod_searchproduct', $params->get('layout', 'giaothuong'));
